package com.kandinfo.base.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.kandinfo.base.admin.constant.CacheConstant;
import com.kandinfo.base.admin.domain.Area;
import com.kandinfo.base.admin.repository.AreaRepository;
import com.kandinfo.base.admin.service.AreaService;
import com.kandinfo.base.common.service.AbstractService;


/**
 * Class Name: AreaServiceImpl Description: 地区
 * 
 * @author wandongwang
 *
 */
@Service
public class AreaServiceImpl extends AbstractService<Area, Long, AreaRepository> implements AreaService {

    @Autowired
    private AreaRepository areaRepository;

    @Resource
    public void setAreaRepository(AreaRepository areaRepository) {
        super.setRepository(areaRepository);
    }

    @Override
	public List<Area> findAllProvince() {
		return areaRepository.findAllProvince();
	}

	@Override
	public List<Area> findArea(Long areaId) {
		return areaRepository.findByParent(areaId);
	}

	/**
     * search area
     */
    @Override
    @Cacheable(value = CacheConstant.AREA_CACHE , key = "'storeArea'")
    public List<Area> getStoreArea() {
        return areaRepository.getStoreArea();
    }

	@Override
	public List<Area> findByParent(Long areaId) {
		return areaRepository.findByParent(areaId);
	}

}
